package com.yuexun.beilunpatient.ui.my.presenter.impl;


import com.yuexun.beilunpatient.base.BaseEntity;
import com.yuexun.beilunpatient.ui.my.model.IResetPasswordModel;
import com.yuexun.beilunpatient.ui.my.presenter.IResetPasswordPresenter;
import com.yuexun.beilunpatient.ui.my.ui.view.IResetPasswordView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by work-jx on 2016/11/23.
 */
public class ResetPasswordPresenter implements IResetPasswordPresenter {
    private IResetPasswordView view;
    private IResetPasswordModel model;

    //记录Log
//    private final Logger log = ProUtil.getLogger(LoginPresneter.class);

    public ResetPasswordPresenter(IResetPasswordModel model, IResetPasswordView view) {
        this.model = model;
        this.view = view;
    }


    @Override
    public void resetPassword(Map<String, String> praise) {
        model.resetPassword(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity>() {

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("修改密码失败");
                    }

                    @Override
                    public void onNext(BaseEntity baseBean) {
                        view.resetPassword(baseBean);
                    }
                });
    }
}
